package com.max.xihu.lambda;

import java.util.Comparator;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @Author: Max
 * @Date: 2020-03-30 22:21
 * @Description:方法引用
 */
public class MethodRefDemo {

    public void method1(){

        Consumer<String> consumer1 = System.out::println;
        consumer1.accept("abcdefg");

        Comparator<Integer> com = (x,y)->Integer.compare(x,y);

        Comparator<Integer> com1 = Integer::compare;

        BiPredicate<String,String> bp = (x,y) -> x.equals(y);

        BiPredicate<String,String> bp1 = String::equals;

    }

    public void method2(){

        Supplier<Human> hum = () -> new Human();

        Supplier<Human> hum2 = Human::new;


        Function<Integer,Human> func = Human::new;

        BiFunction<Integer,String,Human> func2 = Human::new;


    }

    public void method3(){
        Function<Integer,String[]> func1 = String[]::new;
        func1.apply(10);

        Function<Integer,String[]> func2 = (x) -> new String[x];
        func2.apply(10);

    }
}
